<?php
/**
 * @author Biju T biju@poornam.com
 *  
 */
require_once("classes/interface/RequestWrapper.php");

class HttpRequestWrapper implements RequestWrapper{
	
	public $params = array();
	public $method = null;
	public $rurl = null;
	
	function __construct(){
		
	}
	
	public function setRequest($server,$request){
		if($server['REQUEST_METHOD'] == 'GET'){
			$this->method = 'GET';
			$this->initializeGetParams($server['REQUEST_URI']);
		}else{
			$this->method = 'POST';
			$this->initializePostParams($request);
		}
		$url = split("=",$server['REDIRECT_QUERY_STRING']);
		$this->rurl = $url[1];
		return $this;
	}
	
	public function initializeGetParams($ruri){
		$uri = split("\?",$ruri);
		$params = split("&",$uri[1]);
		foreach($params as $param){
			$kv = split("=",$param);
			$key = $kv[0];
			$val = $kv[1];
			$this->params[$key] = $val;
		}
	}
	public function initializePostParams($request){
		foreach($request as $key=>$value){
			$this->params[$key] = $value;
		}
	}
	public function getParameter($name){
		if(isset($this->params[$name])){
			return $this->params[$name];
		}else{
			return null;
		}
	}
}
?>